import 'package:aio/aio.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:app/generated/app_strings.dart';
import 'package:app/src/http/bean/wroks/attachment_bean.dart';
import 'package:app/src/http/bean/wroks/contract_bean.dart';
import 'package:app/src/http/bean/wroks/customers_copyInfo.dart';
import 'package:app/src/http/bean/wroks/product_bean.dart';
import 'package:app/src/ui/app_ui.dart';
import 'package:app/src/ui/route/works/public/items/ui_base.dart';
import 'package:app/src/ui/route/works/public/items/ui_card.dart';
import 'package:app/src/utils/image_path_utils.dart';

///订单信息
class UiOrderInfo {
  ///isOrderschangefactory 是否为更换发货工厂
  static Widget build(BuildContext context, Product? data, Product? oldData,
      {String? title, bool isOrderschangefactory = false}) {
    if (StringUtils.isEmpty(title)) {
      title = AppStrings.of(context).OrderInformation; //订单信息
    }
    List<Widget> children = [];
    children.add(UiBase.title(context, title)); //标题
    children.add(UiBase.item(context, AppStrings.of(context).OrderCode,
        data?.OrderCode, oldData?.OrderCode)); //订单编号
    children.add(UiBase.item(context, AppStrings.of(context).OrderOutCode,
        data?.OrderOutCode, oldData?.OrderOutCode)); //订单外部编号
    children.add(UiBase.item(context, AppStrings.of(context).OrderTypeName,
        data?.getOrderOrStatusName(), oldData?.getOrderOrStatusName(),
        isBlue: true)); //订单状态
    children.add(UiBase.item(context, AppStrings.of(context).ContractCode,
        data?.ContractCode, oldData?.ContractCode)); //合同编号
    children.add(UiBase.item(context, AppStrings.of(context).OrderOutCode,
        data?.OrderOutCode, oldData?.OrderOutCode)); //订单外部编号
    children.add(UiBase.item(context, AppStrings.of(context).OutCode,
        data?.OutCode, oldData?.OutCode)); //合同外部编号
    children.add(UiBase.item(context, AppStrings.of(context).ProjectName,
        data?.ProjectName, oldData?.ProjectName)); //项目名称
    children.add(UiBase.item(context, AppStrings.of(context).CustomerName,
        data?.CustomerName, oldData?.CustomerName)); //客户名称
    children.add(UiBase.item(context, AppStrings.of(context).MerchandiserName,
        data?.MerchandiserName, oldData?.MerchandiserName)); //客服经理
    children.add(UiBase.item(context, AppStrings.of(context).SalesmanName,
        data?.SalesmanName, oldData?.SalesmanName)); //销售经理
    children.add(UiBase.item(context, AppStrings.of(context).FactoryName,
        data?.FactoryName, oldData?.FactoryName,
        isBlue: isOrderschangefactory)); //生产工厂
    children.add(UiBase.item(context, AppStrings.of(context).ProductName,
        data?.ProductName, oldData?.ProductName)); //产品名称
    var productinng = data?.isProduting() ?? false; //判断是否正在生产中
    if (StringUtils.isNotEmpty(data?.OrderShelfStat?.ShelfStatList) &&
        productinng) {
      children.add(UiBase.item(
          context, AppStrings.of(context).TotalMeter, data?.TotalMeter, null,
          unit: "m")); //周长合计
      children.add(UiBase.item(
          context, AppStrings.of(context).TotalSize, data?.TotalSize, null,
          unit: "㎡")); //面积合计
      children.add(UiBase.item(context, AppStrings.of(context).TotalPNum,
          data?.TotalPNum, null)); //片数合计
      children.add(UiBase.item(
          context, AppStrings.of(context).TotalJsSize, data?.TotalJsSize, null,
          unit: "㎡")); //结算合计
    }
    var column = UiBase.column(context, children);
    var card = UiCard.build(context, column);
    return card;
  }
}
